<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>{$meta_title}</title>
  
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="">
  <link rel="apple-touch-icon-precomposed" href="">
  <meta name="apple-mobile-web-app-title" content="{$meta_title}" />
  <link rel="stylesheet" href="__ROOT__/Application/Home/View/default/assets/css/amazeui.min.css"/>
  <link rel="stylesheet" href="__ROOT__/Application/Home/View/default/assets/css/admin.css">
  <link rel="stylesheet" href="__ROOT__/Application/Home/View/default/assets/css/mycss.css">
  <script type="text/javascript">var _config = <?php echo Auth::getConfig();?></script>
  <script type="text/javascript" src="__PUBLIC__/libs/dingding/javascripts/zepto.min.js"></script>
  <script type="text/javascript" src="http://g.alicdn.com/dingding/dingtalk-pc-api/2.6.2/index.js"></script>
  <script type="text/javascript" src="__PUBLIC__/libs/dingding/javascripts/logger.js"></script>
  <style type="text/css">
		.am-form div.am-text-right{padding:7px 0;}
	</style>
</head>
<body>

<div class="am-cf admin-main">
  <!-- sidebar start -->
  <div class="admin-sidebar am-offcanvas" id="admin-offcanvas">
    <div class="am-offcanvas-bar admin-offcanvas-bar">
      <ul class="am-list admin-sidebar-list">
      	<li ><a href="#"><span><img alt="{$user_info.name}" src="{$user_info.avatar}"  style="display: block; margin: 0 auto; width: 80%;border-radius: 50%;"></span> {$user_info.name}</a></li>
        <li ><a href="/Home/Task/shouye"><span class="am-icon-home"></span> 首页</a></li>
        <li ><a href="/Home/Task/mytask"><span class="am-icon-file"></span> 任务</a></li>
        <li><a href="/Home/Task/dongtai"><span class="am-icon-table"></span> 动态</a></li>
        <li class="nav-active"><a href="/Home/Task/addnew"><span class="am-icon-pencil-square-o"></span> 新增</a></li>
       
      </ul>
      
    </div>
  </div>
  <!-- sidebar end -->

<!-- content start -->
<div class="admin-content" style="overflow-y: scroll;">
  <div class="admin-content-body">
    <div class="am-cf am-my-title">{$meta_title}</div>
      
<form class="am-form" id="taskform" action="/Home/Task/addson" method="post">
             
             <div class="am-g am-margin-top">
             <div class="am-u-sm-4 am-u-md-2 am-text-right">搜索</div>
             <div class="am-u-sm-12 am-u-md-4 am-u-end" >
	          <div class="am-input-group am-input-group-sm">
	            <input type="text" class="am-form-field" id="so_project" placeholder="请输入项目ID/名称/编号">
	          <span class="am-input-group-btn">
	            <button class="am-btn am-btn-default" type="button" id="search">搜索</button>
	          </span>
	          </div>
	        </div>
             </div>
             
			  <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">项目编号</div>
	            <div class="am-u-sm-8 am-u-md-4 am-u-end ">
	              <select name="projectid" id="projectid">
	              	<volist name="project_number" id="vo" key="k">
	                <option value="{$vo.id}" <if condition="$vo.id eq $projectid " >selected = "selected"</if>>{$vo.title}</option>
	                </volist>
	              </select>
	            </div>
	          </div>

            <div class="am-g am-margin-top">
              <div class="am-u-sm-4 am-u-md-2 am-text-right">
                负责人
              </div>
              <div class="am-u-sm-8 am-u-md-10 am-u-end col-end">
              	
              	<span class="am-input-group-btn" >
	            <button class="am-btn am-btn-default" type="button" id="find_uid">选人</button>
	          </span>
               
              </div>
            </div>

			<div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">类型</div>
	            <div class="am-u-sm-8 am-u-md-4 am-u-end ">
	              <select name="type">
	                <volist name="task_type" id="vo" key="k">
	                <option value="{$vo.id}">{$vo.title}</option>
	                </volist>
	              </select>
	            </div>
	          </div>
	          
	          <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">紧急级别</div>
	            <div class="am-u-sm-8 am-u-md-4 am-u-end ">
	              <select name="emergency_level">
	                <volist name="emergency_level" id="vo" key="k">
	                <option value="{$vo.id}">{$vo.title}</option>
	                </volist>
	              </select>
	            </div>
	          </div>
               
             <div class="am-g am-margin-top">
              <div class="am-u-sm-4 am-u-md-2 am-text-right">
                发布人
              </div>
              <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                <input type="text" class="am-input-sm"  value="{$user_info.name}" disabled="disabled">
                <input type="hidden"  name="creater" value="{$user_info.userid}">
                <input type="hidden"  name="p_id" value="{$pid}">
              </div>
            </div>     

            <div class="am-g am-margin-top-sm">
              <div class="am-u-sm-12 am-u-md-2 am-text-right admin-form-text">
                任务内容
              </div>
              <div class="am-u-sm-12 am-u-md-6 am-u-end">
                <textarea rows="4" name="content" placeholder="请填写任务详细"></textarea>
              </div>
            </div>

          </form>
   
	<div class="am-margin">
      <button type="button" class="am-btn am-btn-primary am-btn-xs" id="savetask">提交保存</button>
      <button type="button" class="am-btn am-btn-primary am-btn-xs" onClick="javascript :history.back(-1);">放弃保存</button>
    </div>

  </div>
</div>
<!-- content end -->

</div>

<script type="text/javascript" >

//搜索项目
$('#search').click(function(){
	var keyword=$('#so_project').val();
	var params = {};
	params.keyword=keyword;
	
	var url="{:U('Home/Task/getProjectAjax')}";
	$.post(url,params,function(data) {
		
			$('#projectid').html(data);
		
	});
});
//选人
 DingTalkPC.config({
            agentId: _config.agentId,
            corpId: _config.corpId,
            timeStamp: _config.timeStamp,
            nonceStr: _config.nonceStr,
            signature: _config.signature,
            jsApiList: [
                'runtime.permission.requestAuthCode',
                'device.notification.alert',
                'device.notification.confirm',
                'biz.contact.choose',
                'device.notification.prompt',
                'biz.ding.post'
                ] // 必填，需要使用的jsapi列表
        });
 DingTalkPC.ready(function(res){
	 
	 $('#find_uid').on('click', function() {
		
		var lens = 5;
		var user=[];
     	for (var a = 1; a <= lens; a++)
     	{
     		if($('#uid'+a).val()){
     			user[a-1] =$('#uid'+a).val();
     		}
     		
     	} 
     	
        DingTalkPC.biz.contact.choose({
            multiple: true, //是否多选： true多选 false单选； 默认true
            users: user, //默认选中的用户列表，工号；成功回调中应包含该信息
            corpId: _config.corpId, //企业id
            max: 5, //人数限制，当multiple为true才生效，可选范围1-1500
            onSuccess: function(data) {
            	
            	var len = 5;
            	for (var i = 1; i <= len; i++)
            	{
            		$('#user_'+i).remove();
            		var html ="<div class='am-btn' id='user_"+i+"'>"+data[i-1].name+"<span onclick='del_user("+i+");'>X</span><input type='hidden' name='uid"+i+"' id='uid"+i+"' value='"+data[i-1].emplId+"'></div>"
            		$('#find_uid').before(html); 
            	} 
            	          	
        },
        onFail : function(err) {}
    	});
    });
	 
 });
 
 function del_user(i){
	 $('#user_'+i).remove();
 }
//提交表单
	$('#savetask').click(function(){
	 	$('#taskform').submit();
	});
</script>

<script src="__ROOT__/Application/Home/View/default/assets/js/jquery.min.js"></script>

<script src="__ROOT__/Application/Home/View/default/assets/js/amazeui.min.js"></script>
<script src="__ROOT__/Application/Home/View/default/assets/js/app.js"></script>
</body>
</html>
